#include <stdio.h>
#include <stdlib.h>

//https://leetcode.cn/problems/product-of-array-except-self/

int *productExceptSelf(int *nums, int numsSize, int *returnSize) {
    int *ret = (int *) malloc(sizeof(int) * numsSize);
    int product = 1;
    int zeros = 0;
    *returnSize = numsSize;
    for (int i = 0; i < numsSize; i++) {
        if (nums[i] == 0) {
            zeros++;
            continue;
        }
        product *= nums[i];
    }
    if (zeros > 1) {
        product = 0;
    }
    for (int i = 0; i < *returnSize; i++) {
        if (nums[i] == 0) {
            ret[i] = product;
        } else if (zeros > 0) {
            ret[i] = 0;
        } else {
            ret[i] = product / nums[i];
        }
    }
    return ret;
}

int main() {

    return 0;
}